import fetch from 'utils/fetch';

// 查看广告
export function pageHeadLine(
    page,
    rows,
    title,
    status,
    client,
    startUploadTime,
    endUploadTime,
    orderByCreateTime,
    orderByReadNum,
    orderByClickNum,
    stick
) {
    const data = {
        page,
        rows,
        title,
        status,
        client,
        startUploadTime,
        endUploadTime,
        orderByCreateTime,
        orderByReadNum,
        orderByClickNum,
        stick
    };
    return fetch({
        url: '/headLine/pageHeadLine',
        method: 'post',
        data
    });
}

//添加文章

export function insertHeadLine(
    title,
    pic,
    url,
    urlType,
    htmlContent,
    content
) {
    const data = {
        title,
        pic,
        url,
        urlType,
        htmlContent,
        content
    };
    return fetch({
        url: "/headLine/insertHeadLine",
        method: "post",
        data
    })
}

//查看头条
export function getHeadLine(
    pId
) {
    const data = {
        pId
    };

    return fetch({
        url: "/headLine/getHeadLine",
        method: "post",
        data
    })
}

//更新文章

export function updateHeadLine(
    pId,
    title,
    pic,
    url,
    urlType,
    htmlContent,
    content
) {
    const data = {
        pId,
        title,
        pic,
        url,
        urlType,
        htmlContent,
        content
    };

    return fetch({
        url: "/headLine/updateHeadLine",
        method: "post",
        data
    })
}

//删除头条
export function removeHeadLine(
    pId
) {
    const data = {
        pId
    };

    return fetch({
        url: "/headLine/removeHeadLine",
        method: "post",
        data
    })
}

//发布头条
export function uploadHeadLine(
    pId,
    client
) {
    const data = {
        pId,
        client
    };

    return fetch({
        url: "/headLine/uploadHeadLine",
        method: "post",
        data
    })
}

//置顶/取消置顶

export function stickHeadLine(
    pId,
    stick
) {
    const data = {
        pId,
        stick
    };

    return fetch({
        url: "/headLine/stickHeadLine",
        method: "post",
        data
    })
}